bazel_dep(name = "rules_cc", version = "0.2.14")

# temporary to fix missings loads in toolchains_llvm (drop wit Bazel 9 release)
bazel_dep(name = "toolchains_llvm", version = "1.5.0")
git_override(
    module_name = "toolchains_llvm",
    commit = "ace6215bbfe8a76884646b2458b42380e2201607",
    remote = "https://github.com/bazel-contrib/toolchains_llvm.git",
)

# Configure and register the toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
    name = "wasm_toolchain",
    libclang_rt = {
        "@libclang_rt_wasm32//:libclang_rt.builtins-wasm32.a": "wasm32-unknown-unknown/libclang_rt.builtins.a",
    },
    llvm_version = "19.1.0",
    stdlib = {"wasm32": "libc"},
)
llvm.sysroot(
    name = "wasm_toolchain",
    label = "@wasi_sdk_sysroots//wasm32-wasip2",
    targets = ["wasm32"],
)
use_repo(llvm, "wasm_toolchain")

register_toolchains("@wasm_toolchain//:all")

wasi_sdk_sysroots = use_repo_rule("//wasm:wasi_sdk.bzl", "wasi_sdk_sysroots")

wasi_sdk_sysroots(name = "wasi_sdk_sysroots")

libclang_rt_wasm32 = use_repo_rule("//wasm:wasi_sdk.bzl", "libclang_rt_wasm32")

libclang_rt_wasm32(name = "libclang_rt_wasm32")
